package com.HaFuManShu2;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入字符的个数:");
        int n = sc .nextInt();
        HuffmanTree<Character> tree = new HuffmanTree<>(n);
        //创建哈夫曼树
        tree.createTree();
        tree.displayTree();
        tree.createCode();
        tree.displayCode();
        System.out.println("请输入要发送的电文:");
        String text = sc.next();
        String codeText = tree.textCode(text);
        System.out.println("编码后:" + codeText);
        String decodeText = tree.textDecode(codeText);
        System.out.println("译码后：" + decodeText);
    }
}